package com.xushi.bean;

import com.xushi.model.Activity;
import org.springframework.util.CollectionUtils;

import java.util.List;

public class ActivityWrapperBean {
    private int state;
    private String message;
    private Activity activity;

    public ActivityWrapperBean(List<Activity> activeActivities) {
        if (CollectionUtils.isEmpty(activeActivities)) {
            state = 0;
            message = "当前没有有效活动";
        } else {
            // 多个有效活动，取最后一个
            this.activity = activeActivities.get(activeActivities.size() - 1);
            this.activity.setUserTemplate(null);
            ActivityState activityState = ActivityStateBean.getState(activity);
            state = activityState.ordinal();
            message = ActivityStateBean.getStateMeaning(activityState);
        }
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Activity getActivity() {
        return activity;
    }

    public void setActivity(Activity activity) {
        this.activity = activity;
    }
}
